<?php
class User extends CI_Controller{
	public function login_ajax(){
		$u = $_POST['username'];
		$p = $_POST['password'];
		
		$bool = $this->User_model->validate_login($u,$p);
		if($bool == TRUE){
			$this->session->set_userdata('username',$u);
			echo 'true';
		}
		else {
			echo 'false';
		}
	}
	
	public function checkSignedIn(){
		if($this->session->userdata('username')){
			echo 'true';
		}
		else {
			echo 'false';
		}
	}
	
	public function logout(){
		$this->session->unset_userdata('username');
		redirect('home');
	}
	
	public function show_user(){
		$this->load->view('front_end/layout/top-menu-right');
	}
	
	public function show_hello(){
		echo lang('template.hi') . $this->session->userdata('username');
	}
	
	public function show_logout(){
		echo anchor('user/logout',lang('template.logout'));
	}
	
	public function show_profile(){
		echo anchor('user/profile',lang('template.account'));
	}
}